import React, {Component, PropTypes} from 'react';
import { Table  } from 'antd';

export default class User extends Component {
  constructor (props) {
    super(props);

    /**
     * table头部
     * @type {*[]}
     */
    this.columns = [{
      title: '学员id',
      width: 50,
      dataIndex: '$loki'
    },{
      title: '学员姓名',
      width: 100,
      dataIndex: 'user_name'
    }, {
      title: '身份证',
      width: 150,
      dataIndex: 'user_idcard'
    },{
      title: '所属地区',
      width: 150,
      dataIndex: 'user_area'
    },{
      title: '所属考场',
      width: 150,
      dataIndex: 'room_name'
    }];
  }

  componentDidMount () {
    const {examActions, exam} = this.props;
    const examdetail = exam && exam.get('examdetail').toJS();

    if(examdetail && examdetail.exam_user_path){
      examActions.getUserList({
        path : examdetail.exam_user_path
      })
    }
  }

  render() {
    const {exam} = this.props;
    const list = exam.get('userList') && exam.get('userList').toArray();

    const pagination = {
      total : list ? list.length : 0,
      pageSize : 20
    }
    return (
      <div className="ant-table-wraper">
        <Table
          className="ant-room-table"
          bordered
          columns={this.columns}
          dataSource={list}
          pagination={pagination}
        />
        {
          pagination.total > 0 && <div className="ant-table-extend">共导入学员<b>{pagination.total}</b>名</div>
        }
      </div>
    )
  }

}
